package com.ee.chat.admin.controller.auditmanage;

import com.ee.chat.admin.service.IAuditService;
import com.ee.chat.common.bean.Result;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * @Author Shane
 * @Date 2019/10/7 17:39
 */
@RestController
@RequestMapping("audit")
public class AuditContrller {
    private Logger log = LoggerFactory.getLogger(AuditContrller.class);

    @Resource
    IAuditService auditService;

    /**
     * 认证审核列表
     * @Author Shane
     * @Date 2019/10/9 23:43
     * @param
     * @return
     */
    @RequestMapping("auth/list")
    public Result authList(HttpServletRequest request, @RequestParam Integer page, @RequestParam Integer limit,
                       Integer userId, Integer status, String createTime){
        try {
            return auditService.authList(request, page, limit, userId, status, createTime);
        } catch (Exception e){
            log.error("【获取认证审核列表错误】", e);
        }
        return Result.returnFailure();
    }

    /**
     * 认证审核
     * @Author Shane
     * @Date 2019/10/10 0:47
     * @param id        认证记录id
     * @param status    审核状态，1-通过  2-拒绝
     * @return
     */
    @RequestMapping("auth/audit")
    public Result authAudit(HttpServletRequest request, @RequestParam Integer id, @RequestParam Integer status, Integer type, String reason){
        try {
            return auditService.authAudit(request, id, status, type, reason);
        } catch (Exception e){
            log.error("【认证审核错误】", e);
        }
        return Result.returnFailure();
    }

    /**
     * 认证撤销审核
     * @Author AppiJ
     * @Date 2021/1/5 10:24
     * @param id        认证记录id
     * @return
     */
    @RequestMapping("auth/cancelAudit")
    public Result authCancelAudit(HttpServletRequest request, @RequestParam Integer id, String reason){
        try {
            return auditService.authCancelAudit(request, id, reason);
        } catch (Exception e){
            log.error("【认证撤销审核错误】", e);
        }
        return Result.returnFailure();
    }

    /**
     * 用户注册审核列表
     * @Author Shane
     * @Date 2019/10/9 23:43
     * @param
     * @return
     */
    @RequestMapping("register/list")
    public Result registerList(HttpServletRequest request, @RequestParam Integer page, @RequestParam Integer limit,
                               Integer userId, String name, String createTime, Integer status){
        try {
            return auditService.registerList(request, page, limit, userId, name, createTime, status);
        } catch (Exception e){
            log.error("【获取注册审核列表错误】", e);
        }
        return Result.returnFailure();
    }

    /**
     * 用户注册审核
     * @Author Shane
     * @Date 2019/10/10 0:47
     * @param id        认证记录id
     * @param status    审核状态，1-通过  2-拒绝
     * @return
     */
    @RequestMapping("register/audit")
    public Result registerAudit(HttpServletRequest request, @RequestParam Integer id, @RequestParam Integer status, Integer type, String reason){
        try {
            return auditService.registerAudit(request, id, status, type, reason);
        } catch (Exception e){
            log.error("【用户注册审核错误】", e);
        }
        return Result.returnFailure();
    }

    /**
     * 用户注册撤销审核
     * @Author AppiJ
     * @Date 2021/1/5 14:53
     * @param
     * @return
     */
    @RequestMapping("register/cancelAudit")
    public Result registerCancelAudit(HttpServletRequest request, @RequestParam Integer id, String reason){
        try {
            return auditService.registerCancelAudit(request, id, reason);
        } catch (Exception e){
            log.error("【用户注册撤销审核错误】", e);
        }
        return Result.returnFailure();
    }

    /**
     * 资料更新审核列表
     * @Author AppiJ
     * @Date 2020/5/26 18:32
     * @param  item  审核资料类型 如：icon
     * @return
     */
    @RequestMapping("userInfo/list")
    public Result userInfoList(HttpServletRequest request, @RequestParam Integer page, @RequestParam Integer limit,
                               @RequestParam String item, Integer userId, String createTime, Integer status){
        try{
            return auditService.userInfoList(request, page, limit, userId, item, createTime, status);
        }catch (Exception e){
            log.error("【获取资料更新审核列表错误】", e);
        }
        return Result.returnFailure();
    }

    /**
     * 资料更新审核
     * @Author AppiJ
     * @Date 2020/6/1 16:48
     * @param
     * @return
     */
    @RequestMapping("userInfo/audit")
    public Result userInfoAudit(HttpServletRequest request, @RequestParam String item, @RequestParam Integer id,
                                @RequestParam Integer status, Integer type, String reason){
        try {
            return auditService.userInfoAudit(request, item, id, status, type, reason);
        } catch (Exception e){
            log.error("【资料更新审核错误】", e);
        }
        return Result.returnFailure();
    }

    /**
     * 资料更新撤销审核
     * @Author AppiJ
     * @Date 2021/1/5 10:30
     * @param
     * @return
     */
    @RequestMapping("userInfo/cancelAudit")
    public Result userInfoCancelAudit(HttpServletRequest request, @RequestParam Integer id, @RequestParam String item, String reason){
        try {
            return auditService.userInfoCancelAudit(request, id, item, reason);
        } catch (Exception e){
            log.error("【资料更新撤销审核错误】", e);
        }
        return Result.returnFailure();
    }

    /**
     * 获取待审核消息数量
     * @Author AppiJ
     * @Date 2020/9/12 13:43
     * @param
     * @return
     */
    @RequestMapping("getNotAuditNum")
    public Result getNotAuditNum(HttpServletRequest request){
        try {
            return auditService.getNotAuditNum(request);
        } catch (Exception e){
            log.error("【获取待审核消息数量错误】", e);
        }
        return Result.returnFailure();
    }
}
